<template>
  <BasicModal v-bind="$attrs" @register="registerModal" title="详情" width="60%" destroyOnClose
              :footer="null">
    <Description :column="1" :data="dataInfo" :schema="formSchema" />
  </BasicModal>
</template>
<script lang="ts" setup>
import { ref, useAttrs } from 'vue';
import { Description, useDescription } from '/@/components/Description/index';
import BasicModal from "/@/components/Modal/src/BasicModal.vue";
import {useModalInner} from "/@/components/Modal";
const emit = defineEmits(['register']);
const attrs = useAttrs();
const dataInfo = ref({});
const  formSchema =    [
  {
    label: '投入品',
    field: 'inputs_dictText',
  },
  {
    label: '规格',
    field: 'inputs_spec',
  },
  {
    label: '批次号',
    field: 'batchDescription',
  },
  {
    label: '采购数量',
    field: 'number',
  },
  {
    label: '费用',
    field: 'cost',
  },
  {
    label: '经销商',
    field: 'distributor',
  },
  {
    label: '采购时间',
    field: 'buyTime',
  },
  {
    label: '采购人',
    field: 'purchaser',
  },
]
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
  setModalProps({ confirmLoading: false });
  console.log(data);
  dataInfo.value = data.record;
  if (data.record.inputs) {
    dataInfo.value.inputs_dictText = data.record.inputs.name;
    dataInfo.value.inputs_spec = data.record.inputs.popularName;
  }else {
    dataInfo.value.inputs_dictText = ''
    dataInfo.value.inputs_spec = ''
  }
  console.log(dataInfo.value);
});
</script>
